raise Exception, exn
-def restore(xd, fd, dominfo = None):
+def restore(xd, fd, dominfo = None, paused = False):
signature = read_exact(fd, len(SIGNATURE),
"not a valid guest state file: signature read")
if signature != SIGNATURE:
os.read(fd, 1) # Wait for source to close connection
dominfo.waitForDevices() # Wait for backends to set up
- dominfo.unpause()
+ if not paused:
+ dominfo.unpause()
dominfo.completeRestore(handler.store_mfn, handler.console_mfn)
# !!!
raise XendError("Unsupported")
- def domain_restore(self, src):
+ def domain_restore(self, src, paused=False):
"""Restore a domain from file.
@param src: filename of checkpoint file to restore from
try:
fd = os.open(src, os.O_RDONLY)
try:
- return self.domain_restore_fd(fd)
+ return self.domain_restore_fd(fd, paused=paused)
finally:
os.close(fd)
except OSError, ex:
raise XendError("can't read guest state file %s: %s" %
(src, ex[1]))
- def domain_restore_fd(self, fd):
+ def domain_restore_fd(self, fd, paused=False):
"""Restore a domain from the given file descriptor.
@param fd: file descriptor of the checkpoint file
"""
try:
- return XendCheckpoint.restore(self, fd)
+ return XendCheckpoint.restore(self, fd, paused=paused)
except:
# I don't really want to log this exception here, but the error
# handling in the relocation-socket handling code (relocate.py) is
'Migrate a domain to another machine.'),
'pause' : ('<Domain>', 'Pause execution of a domain.'),
'reboot' : ('<Domain> [-wa]', 'Reboot a domain.'),
- 'restore' : ('<CheckpointFile>',
+ 'restore' : ('<CheckpointFile> [-p]',
'Restore a domain from a saved state.'),
'save' : ('<Domain> <CheckpointFile>',
'Save a domain state to restore later.'),
('-L', '--live', 'Dump core without pausing the domain'),
('-C', '--crash', 'Crash domain after dumping core'),
),
+ 'restore': (
+ ('-p', '--paused', 'Do not unpause domain after restoring it'),
+ ),
}
common_commands = [
server.xend.domain.save(domid, savefile)
def xm_restore(args):
- arg_check(args, "restore", 1)
+ arg_check(args, "restore", 1, 2)
+
+ try:
+ (options, params) = getopt.gnu_getopt(args, 'p', ['paused'])
+ except getopt.GetoptError, opterr:
+ err(opterr)
+ sys.exit(1)
+
+ paused = False
+ for (k, v) in options:
+ if k in ['-p', '--paused']:
+ paused = True
+
+ if len(params) != 1:
+ err("Wrong number of parameters")
+ usage('restore')
+ sys.exit(1)
- savefile = os.path.abspath(args[0])
+ savefile = os.path.abspath(params[0])
if not os.access(savefile, os.R_OK):
err("xm restore: Unable to read file %s" % savefile)
sys.exit(1)
- server.xend.domain.restore(savefile)
+ server.xend.domain.restore(savefile, paused)
def getDomains(domain_names, full = 0):